<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>主页</title>
	</head>
	<script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
	<script src="__PUBLIC__/js/jquery.mobile-1.4.5.min.js" type="text/javascript"></script>
	<link href="__PUBLIC__/css/jquery.mobile-1.4.5.min.css" type="text/css" rel="stylesheet" />
	<link href="__PUBLIC__/css/all.css" type="text/css" rel="stylesheet" />

	<body>
		<!--新建挂号-->
		<div data-role="page" id="newregisters">
			<style>
				/*新建挂号css*/
				
				#ills {
					width: 100%;
					height: 200px !important;
					resize: none;
				}
				#newregister {
					height: 100% !important;
					padding: 10%;
				}
				#buttons {
					text-align: center;
				}
				.but {
					display: inline-block;
					width: 40% !important;
				}
				span {
					font-size: 10px;
					font-size: 1.0rem !important;
				}
				.ui-btn{
					font-size: 10px;
					font-size: 1.0rem !important;
				}
			</style>
			<script>
				 //新建挂号js
				function change() {
					var Dvalue = $("#day").val();
					var yugi = function(n) {
						var now = new Date;
						now.setDate(now.getDate() + parseInt($('#day').val()));
						return now;
					}
					var date = yugi(Dvalue)
					var mon = date.getMonth() + 1
					$("#data")
						.html("挂号日期：" + date.getFullYear() + "-" + mon + "-" + date.getDate())
						.css("color", "black")
				}

				function check() {
					var textareas = $("#ills").val();
					if (textareas.length > 19||true) {
						var date = new Date;
						date.setDate(date.getDate()+parseInt($('#day').val()));
						$.ajax({
							url : "{:U('Users/sendRegs')}",
							type: 'POST',
							dataType : 'json' ,
							data:{
								'order_date' : new Date,
								'see_date' : date,
								'day'		:date.getDay(),
								'see_time' : $('#time').val(),
								'type'		: $('#doctorname').val(),
								'sick'		: textareas,
							},success:function(json){
//								if(json==true){
//									alert("挂号成功");
//								}else{
//									alert("挂号失败");
//								}
								alert(json);
								console.log(json);
							}
						});
						$("#ills").val("")
						clearn()
					} else {
						$("#data")
							.html("请认真填写好主要病症")
							.css("color", "red")
					}
				}

				function clearn() {
					change()
				}



				$(document).ready(function() {
					var date = new Date;
					var mon = date.getMonth() + 1;
					var day = date.getDate()+1;
					$("#data").html("挂号日期：" + date.getFullYear() + "-" + mon + "-" + day);
				})
			</script>
			<div data-role="header" data-position="fixed">
				<div data-role="navbar" data-iconpos="left">
					<ul>
						<li><a href="{:U('Users/information')}" >个人信息</a></li>
						<li><a href="register.html" >挂号记录</a></li>
						<li><a href="revise.html">修改密码</a></li>
					</ul>
				</div>
			</div>

			<form id="newregister">
				<label for="data" id="data">挂号日期：</label>

				<select name="day" id="day" data-native-menu="false" onchange="change()">
					<option value=1>1天后</option>
					<option value=2>2天后</option>
					<option value=3>3天后</option>
					<option value=4>4天后</option>
					<option value=5>5天后</option>
					<option value=6>6天后</option>
				</select>
				<select name="time" id="time" data-native-menu="false">
					<option value=1>上午</option>
					<option value=2>下午</option>
				</select>
				<label for="doctorname">科目：</label>
				<select name="doctorname" id="doctorname"  data-native-menu="false">
					<option value=1>内科</option>
					<option value=2>外科</option>
					<option value=3 selected="selected">请选择</option>

				</select>
				<label for="doctorselect">医生：</label>
				<select name="doctorselect" id="doctorselect"  data-native-menu="false">
				</select>
				<label for="ills">主要病症：</label>
				<textarea id="ills" placeholder="请至少输入20个字" onclick="clearn()"></textarea>
				<div id="buttons">
					<button class="but" id="sure_ill" type="button" onclick="check()">确定</button>
					<button class="but" type="button">取消</button>
				</div>
			</form>

			<div data-role="footer" data-position="fixed">
				<div data-role="navbar" data-iconpos="left">
					<ul>
						<li><a href="{:U('Users/newregisters')}" data-icon="home">主页</a></li>
						<li><a href="{:U('Users/information')}" data-icon="user">我</a></li>
						<li><a href="#" data-icon="cloud" id="navmes">更多</a></li>
					</ul>
				</div>
			</div>
		</div>
	</body>
</html>